import launch
import launch_ros
import launch.event_handlers
def generate_launch_description():
    launch_description = launch.LaunchDescription()
    action_node_topic_publisher=launch_ros.actions.Node(
        package="node_pkg",
        # 节点文件名称
        executable="topic_publisher", 
        # 节点名称
        name="topic_publisher",
    )
    action_node_topic_subscriber=launch_ros.actions.Node(
        package="node_pkg",
        executable="topic_subscriber",
        name="topic_subscriber",
    )
    launch_description.add_action(action_node_topic_subscriber)
    # 按顺序启动
    launch_description.add_action(launch.actions.RegisterEventHandler(
        event_handler= launch.event_handlers.OnProcessStart(
            target_action= action_node_topic_subscriber,
            on_start=[
                launch.actions.LogInfo(msg="start action_node_topic_subscriber------------"),
                action_node_topic_publisher
            ]
        )
    ))
    return launch_description